import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Login from "../views/login/index.vue";
import Home from "../views/home/index.vue";
import Layout from '@/layouts/index.vue'
const routes: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "login",
    component: Login,
  },
  {
    path: "/",
    name: "",
    component: Layout,
  },
  {
    path: "/401",
    name: "401",
    component: import("../views/401.vue")
  },
  {
    path: "/404",
    name: "404",
    component: import('../views/404.vue'),
  },
  // {
  //   path: "*",
  //   redirect: "/404"
  // }
];

const router = createRouter({
  // 根据你使用的模式，必须用适当的函数替换他
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;

/**
 * 破坏性变化
 * new Router => createRouter()
 * 新的history配置取代mode  createWebHistory
 * 删除了*(通配符)路由  自定义的regex参数来定义所有路由
 * 删除<router-link></router-link>中的append属性
 * 删除router-link中的event tag exact属性
 *
*/